<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
@include("layouts.common.head")
<!-- Fonts -->
    <link href="{{ asset('static/css/company/common.css') }}?v={{time()}}" rel="stylesheet">
    <link href="{{ asset('static/css/company/company_jobs.css') }}" rel="stylesheet">
    <!-- Styles -->
    <style>
        html {
            overflow-y: scroll;
        }
    </style>
</head>
<body>
<div id="app">
    @include("layouts.nav")
    @include("company.job.other_top_nav")
    <div class="user_main">
        <div class="mleft">
            @include('company.job.left')
        </div>
        <div class="mright">
            <div class="user_pagetitle">
                <div class="pat_l">
                    {{--修改职位--}}

                    发布职位

                </div>
                <div class="pat_r">(注：带&nbsp;<span class="asterisk"></span> 号为必填项)</div>
                <div class="clear"></div>
            </div>
            <div class="user_tip w880">
                <div class="tiptit">小提示</div>
                <div class="tiptxt link_blue">
                    亲爱的HR，您的帐号可同时发布100个职位，现已发布20个职位。
                </div>
            </div>
            <div class="modTitle">职位信息</div>
            <form id="jobs_form" action="" method="post">
                <div class="mod J_focus">
                    <div class="mb16">
                        <div class="modKey"><span></span>职位名称：</div>
                        <div class="modVal">
                            <div class="fl">
                                <input name="jobs_name" id="jobs_name" type="text" class="input_245_34 fl"
                                       value="{{isSet($job->jobs_name)?$job->jobs_name:""}}">
                            </div>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <div class="mb16">
                        <div class="modKey"><span></span>职位类别：</div>
                        <div class="modVal">
                            <div class="select_input_multi select_205_34 fl J_hoverinput" id="J_showmodal_jobs"
                                 data-title="请选择职位类别" data-multiple="false" data-addjob="true" data-maxnum="0"
                                 data-width="520" data-category="">
                                <span title=""
                                      class="result J_resuletitle_jobs">{{isSet($job->category_cn)?$job->category_cn:""}}</span>
                                <input class="J_resultcode_jobs" name="jobcategory" id="jobcategory" type="hidden"
                                       value="{{isSet($job->category)?$job->category:0}}">
                                <div class="clear"></div>
                            </div>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <div class="mb16">
                        <div class="modKey"><span></span>工作地区：</div>
                        <div class="modVal">
                            <input type="text" id="district" name="district" class="input_205_34 fl" placeholder=""
                                   value="{{isSet($job->district_cn)?$job->district_cn:""}}" readonly>
                        </div>
                        <input type="hidden" name="harea" data-id="0" id="harea"
                               value="{{isSet($job->area_cn)?$job->area_cn:""}}">
                        <input type="hidden" name="hproper" data-id="0" id="hproper"
                               value="{{isSet($job->proper_cn)?$job->proper_cn:""}}">
                        <input type="hidden" name="hcity" data-id="0" id="hcity"
                               value="{{isSet($job->city_cn)?$job->city_cn:""}}">

                        <input type="hidden" name="area" id="area" value="{{isSet($job->area)?$job->area:""}}">
                        <input type="hidden" name="proper" id="proper" value="{{isSet($job->proper)?$job->proper:""}}">
                        <input type="hidden" name="city" id="city" value="{{isSet($job->city)?$job->city:""}}">
                        <div class="clear"></div>
                    </div>
                    <div class="mb16">
                        <div class="modKey"><span></span>薪资待遇：</div>
                        <div class="modVal">
                            <div class="input_unit nopl w110 fl">
                                <input name="minwage" id="minwage" data-title=""
                                       value="@if(isSet($job->negotiable) && $job->negotiable == 0) {{$job->min_wage}} @endif"
                                       class="input_val pdl w110" type="text" placeholder="最低薪资"
                                       onkeyup="if(event.keyCode !=37 &amp;&amp; event.keyCode != 39) value=value.replace(/\D/g,'');"
                                       onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))">
                                <div class="unit">元/月</div>
                            </div>
                            <div class="fl partition">-</div>
                            <div class="input_unit nopl w110 fl">
                                <input name="maxwage" id="maxwage" data-title=""
                                       value="@if(isSet($job->negotiable) && $job->negotiable == 0) {{$job->max_wage}} @endif"
                                       class="input_val pdl w110" type="text" placeholder="最高薪资"
                                       onkeyup="if(event.keyCode !=37 &amp;&amp; event.keyCode != 39) value=value.replace(/\D/g,'');"
                                       onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))">
                                <div class="unit">元/月</div>
                            </div>
                            <label class="checkBox ml20 fl" for="J_negotiable">
                                <input id="J_negotiable" class="J_switch" name="negotiable" id="negotiable" value="1"
                                       type="checkbox"
                                       @if(isSet($job->negotiable) && $job->negotiable == 1) checked="checked" @endif>面议
                            </label>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <div class="mb16">
                        <div class="modKey">条件限制：</div>
                        <div class="modVal">
                            <div class="select_input w113 fl mr10 J_hoverinput J_dropdown J_listitme_parent">
                                <span class="J_listitme_text"><?php echo (isSet($job->education) && isSet($book['_education'][$job->education])) ? $book['_education'][$job->education] : "学历不限" ?></span>
                                <div class="dropdowbox13 J_dropdown_menu">
                                    <div class="dropdow_inner13">
                                        <ul class="nav_box">
                                            <li><a class="J_listitme" href="javascript:;" data-code="0">不限</a></li>
                                            @foreach($book['_education'] as $key=>$item)
                                                <li><a class="J_listitme" href="javascript:;"
                                                       data-code="{{$key}}">{{$item}}</a></li>
                                            @endforeach

                                        </ul>
                                    </div>
                                </div>
                                <input class="J_listitme_code" name="education" id="education" type="hidden"
                                       value="{{isSet($job->education)?$job->education:0}}"/>
                            </div>
                            <div class="select_input w113 fl mr10 J_hoverinput J_dropdown J_listitme_parent">
                                <span class="J_listitme_text">{{ (isSet($job->education) && isSet($book['_experience'][$job->experience]))?$book['_experience'][$job->experience]:"经验不限"}}</span>
                                <div class="dropdowbox13 J_dropdown_menu">
                                    <div class="dropdow_inner13">
                                        <ul class="nav_box">
                                            <li><a class="J_listitme" href="javascript:;" data-code="0">不限</a></li>
                                            @foreach($book['_experience'] as $key=>$item)
                                                <li><a class="J_listitme" href="javascript:;"
                                                       data-code="{{$key}}">{{$item}}</a>
                                                </li>
                                            @endforeach
                                        </ul>
                                    </div>
                                </div>
                                <input class="J_listitme_code" name="experience" id="experience" type="hidden"
                                       value="{{isSet($job->experience)?$job->experience:0}}"/>
                            </div>
                            <div class="select_input w113 fl mr10 J_hoverinput J_dropdown J_listitme_parent">
                                <?php $sex_arr = ['不限', '男', '女']?>
                                <span class="J_listitme_text">{{(isSet($job->education) && isSet($sex_arr[$job->sex]))?$sex_arr[$job->sex]:"性别不限"}}</span>
                                <div class="dropdowbox13 J_dropdown_menu">
                                    <div class="dropdow_inner13">
                                        <ul class="nav_box">
                                            <li><a class="J_listitme" href="javascript:;" data-code="0">不限</a></li>
                                            <li><a class="J_listitme" href="javascript:;" data-code="1">男</a></li>
                                            <li><a class="J_listitme" href="javascript:;" data-code="2">女</a></li>
                                        </ul>
                                    </div>
                                </div>
                                <input class="J_listitme_code" name="sex" id="sex" type="hidden"
                                       value="{{isSet($job->sex)?$job->sex:0}}"/>
                            </div>
                            <input name="amount" id="amount" type="text" class="input_110_34 w113 fl"
                                   value="{{isSet($job->amount)?$job->amount:""}}"
                                   onkeyup="if(event.keyCode !=37 &amp;&amp; event.keyCode != 39) value=value.replace(/\D/g,'');"
                                   onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"
                                   placeholder="招聘人数">
                        </div>
                        <div class="clear"></div>
                    </div>
                    <div class="mb16">
                        <div class="modKey"><span></span>职位描述：</div>
                        <div class="modVal">
                            <textarea name="contents" id="contents" cols="" rows=""
                                      class="textarea_638_80 w518">{{isSet($job->contents)?$job->contents:""}}</textarea>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <div class="mb16">
                        <div class="modKey"><span></span>联系电话：</div>
                        <div class="modVal">
                            <div class="fl">
                                <input name="mobile" id="mobile" type="text" class="input_245_34 fl"
                                       value="{{isSet($job->mobile)?$job->mobile:""}}">
                            </div>
                        </div>
                        <div class="clear"></div>
                    </div>

                    <div class="mb30"></div>
                    <div class="mb16">
                        <div class="modKey">&nbsp;</div>
                        <div class="modVal">
                            <input name="id" type="hidden" id="id" value="{{isSet($job->id)?(int)$job->id:0}}">
                            <input type="button" id="J_release" class="btn_blue J_hoverbut btn_80_38 w140" data-title=""
                                   value="保存职位">
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
            </form>
        </div>
        <div class="clear"></div>
    </div>
    <script type="text/javascript" src="{{asset('static/js/jquery.disappear.tooltip.js')}}"></script>
    <script type="text/javascript" src="{{asset('static/js/jquery.dropdown.js')}}"></script>
    <script type="text/javascript" src="{{asset('static/js/jquery.listitem.js')}}"></script>
    <script type="text/javascript" src="{{asset('static/js/jquery.modal.userselectlayer.js')}}"></script>
    <script type="text/javascript" src="{{asset('static/js/area/Popt.js')}}"></script>
    <script type="text/javascript" src="{{asset('static/js/area/cityJson.js')}}?v=<?php echo time()?>"></script>
    <script type="text/javascript" src="{{asset('static/js/area/citySet.js')}}?v=<?php echo time()?>"></script>
    <script type="text/javascript">
        $("#district").click(function (e) {
            SelCity(this, e);
        });
        var _trade = '<?php echo $category ?>';
        $('.J_other').click(function () {
            $(this).hide();
            $('.J_contact').show();
            $('.J_basic').attr('checked', false);
        });
        $('.J_basic').click(function () {
            if (!$(this).is(":checked")) {
                $('.J_other').hide();
                $('.J_contact').show();
                $('.J_basic').attr('checked', false);
            } else {
                $('.J_other').show();
                $('.J_contact').hide();
                $('.J_basic').attr('checked', true);
            }
        });

        $('.J_other').click();


        // 单选值切换
        $('.J_switch').click(function (event) {
            if ($(this).is(':checked')) {
                $(this).val('1');
            } else {
                $(this).val('0');
            }
        });

        if ($('#J_negotiable').is(':checked')) {
            $('#J_negotiable').closest('.modVal').find('.input_val').val('').prop('disabled', !0);
        }
        // 面议选中后，最低和最高薪资不能编辑
        $('#J_negotiable').die().live('click', function (event) {
            if ($(this).is(':checked')) {
                $(this).closest('.modVal').find('.input_val').val('').prop('disabled', !0);
            } else {
                $(this).closest('.modVal').find('.input_val').each(function (index, el) {
                    $(this).val($(this).data('title')).prop('disabled', 0);
                });
            }
        });


        $('#J_release').click(function () {
                $('#J_release').addClass('btn_disabled').prop('disabled', !0);
                var id = $.trim($('#id').val());
                var jobs_name = $.trim($('#jobs_name').val());
                var category = $.trim($('#jobcategory').val());
                var min_wage = $.trim($('#minwage').val());
                var max_wage = $.trim($('#maxwage').val());
                var negotiable = $('#J_negotiable').is(":checked") ? 1 : 0;
                //限制条件
                var education = $('#education').val();
                var experience = $('#experience').val();
                var sex = $('#sex').val();
                var amount = $('#amount').val();
                //地区
                var area = $.trim($("input[name=area]").val());
                var area_cn = $.trim($("input[name=harea]").val());
                var proper = $.trim($("input[name=proper]").val());
                var proper_cn = $.trim($("input[name=hproper]").val());
                var city = $.trim($("input[name=city]").val());
                var city_cn = $.trim($("input[name=hcity]").val());


                var district = $.trim($("input[name=district]").val());

                var contents = $.trim($('#contents').val());
                var mobile = $.trim($('#mobile').val());
                if (jobs_name === "") {
                    disapperTooltip("remind", "请填写职位名称");
                    $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                    return false;
                }
                if (category === "") {
                    disapperTooltip("remind", "请选择职位类别");
                    $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                    return false;
                }
                if (!$('#J_negotiable').is(':checked')) {
                    if (!min_wage.length || min_wage === 0) {
                        disapperTooltip("remind", "请填写最低薪资");
                        $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                        return false;
                    }

                    if (!max_wage.length) {
                        disapperTooltip("remind", "请填写最高薪资");
                        $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                        return false;
                    }
                    if (parseInt(max_wage) < parseInt(min_wage)) {
                        disapperTooltip("remind", "最高薪资不能低于最低薪资");
                        $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                        return false;
                    }
                    if (parseInt(max_wage) > (parseInt(min_wage) * 2)) {
                        disapperTooltip("remind", "最高薪资不能超过最低薪资的2倍");
                        $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                        return false;
                    }
                }
                if (contents === "") {
                    disapperTooltip("remind", "请填写职位描述");
                    $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                    return false;
                }
                if (contents === "") {
                    disapperTooltip("remind", "请填写职位描述");
                    $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                    return false;
                }
                if (area === "0") {
                    disapperTooltip("remind", "请填写完整的工作地区");
                    $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                    return false;
                }

                if (!regularMobile.test(mobile)) {
                    disapperTooltip("remind", "手机号格式错误");
                    $('#J_release').removeClass('btn_disabled').prop('disabled', 0);
                    return false;
                }
                $('#J_release').val('保存中...').addClass('btn_disabled').prop('disabled', !0);
                $.ajax({
                    url: "{{url('job/edit')}}",
                    type: 'POST',
                    dataType: 'json',
                    data: {
                        id: id,
                        jobs_name: jobs_name,
                        category: category,
                        min_wage: parseInt(min_wage),
                        max_wage: parseInt(max_wage),
                        negotiable: negotiable,
                        education: education,
                        experience: experience,
                        sex: sex,
                        city: city,
                        city_cn: city_cn,
                        proper: proper,
                        proper_cn: proper_cn,
                        area: area,
                        area_cn: area_cn,
                        amount: amount,
                        mobile: mobile,
                        contents: contents
                    }
                }).done(function (data) {
                    if (parseInt(data.status)) {
                        disapperTooltip('success', data.msg);
                        location.href = data.data.url;
                        // 判断是否开启了职位打赏
                    } else {
                        $('#J_release').val($('#J_release').data('title')).removeClass('btn_disabled').prop('disabled', 0);
                        disapperTooltip("remind", data.msg);
                    }
                }).fail(function (result) {
                    $('#J_release').val($('#J_release').data('title')).removeClass('btn_disabled').prop('disabled', 0);
                    disapperTooltip("remind", result.msg);
                });
            }
        );

        // 高级设置标签开关
        $('.switch-icon').die().live('click', function () {
            if ($(this).hasClass('dot-click')) return false;
            $(this).toggleClass('selected');
        });

        // 是否开启职位打赏
        $('#jobMoneyControl').die().live('click', function () {
            if ($(this).hasClass('selected')) {
                $("#jobMoney").val(1);
            } else {
                $("#jobMoney").val(0);
            }
        });
        // 是否邮件接收投递的简历
        $('#notifyControl').die().live('click', function () {
            if ($(this).hasClass('selected')) {
                $("#notify").val(1);
            } else {
                $("#notify").val(0);
            }
        });
        // 是否联系手机接收投递简历的通知
        $('#phoneControl').die().live('click', function () {
            if ($(this).hasClass('selected')) {
                $("#notify_mobile").val(1);
            } else {
                $("#notify_mobile").val(0);
            }
        });
    </script>
</div>
</body>
</html>
